package com.lh.web;

import com.lh.createBean.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

@Controller
public class TestController {

    @GetMapping("/test")
    @ResponseBody
    public String test(String name, Student student){
        return "SpringMVC!";
    }

    @GetMapping("/test02")
    public String test02(String name, RedirectAttributes attr){
        //重定向携带数据
        attr.addFlashAttribute("name",name);
        return "index";
    }

}
